package com.sc.nft.admin.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sc.nft.admin.request.IdRequest;
import com.sc.nft.annotation.SysMemberLogin;
import com.sc.nft.entity.dto.AddUserCityServerCentreExtraAwardDTO;
import com.sc.nft.entity.dto.SaveUserCityServerCentreExtraAwardDTO;
import com.sc.nft.entity.dto.UserCityServerCentreExtraAwardPageListDTO;
import com.sc.nft.entity.vo.UserCityServerCentreExtraAwardPageListVO;
import com.sc.nft.service.UserCityServerCentreExtraAwardService;
import com.sc.nft.sup.PageResult;
import com.sc.nft.sup.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("/admin/userCityServerCentreExtraAward")
@Api(tags = "城市服务中心额外奖励")
public class UserCityServerCentreExtraAwardController {

    private final UserCityServerCentreExtraAwardService userCityServerCentreExtraAwardService;

    @ApiOperation(value = "获取市场补贴配置列表", notes = "获取市场补贴配置列表", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @PostMapping(value = "/getPageList", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public PageResult<UserCityServerCentreExtraAwardPageListVO> getPageList(@RequestBody UserCityServerCentreExtraAwardPageListDTO userCityServerCentreExtraAwardPageListDTO) {
        Page<UserCityServerCentreExtraAwardPageListVO> pageList = userCityServerCentreExtraAwardService.getPageList(userCityServerCentreExtraAwardPageListDTO);
        return PageResult.success(pageList);
    }

    @ApiOperation(value = "移除某条数据", notes = "移除某条数据", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @PostMapping(value = "/deleteById", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public Result deleteById(@RequestBody IdRequest idRequest) {
        userCityServerCentreExtraAwardService.deleteById(idRequest.getId());
        return Result.success();
    }

    @ApiOperation(value = "新增", notes = "新增", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @PostMapping(value = "/add", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public Result add(@RequestBody AddUserCityServerCentreExtraAwardDTO addUserCityServerCentreExtraAwardDTO) {
        userCityServerCentreExtraAwardService.add(addUserCityServerCentreExtraAwardDTO);
        return Result.success();
    }

    @ApiOperation(value = "修改", notes = "修改", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @PostMapping(value = "/updateById", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public Result updateById(@RequestBody List<SaveUserCityServerCentreExtraAwardDTO> saveUserCityServerCentreExtraAwardDTO) {
        userCityServerCentreExtraAwardService.updateById(saveUserCityServerCentreExtraAwardDTO);
        return Result.success();
    }

}
